// 该属性用于隐藏对未使用代码的警告
#![allow(dead_code)]

fn main() {
    inspect(WebEvent::KeyPress('你'));
    inspect(WebEvent::Paste("my text".to_owned()));
    inspect(WebEvent::Click { x: 1, y: 2 });
    inspect(WebEvent::PageLoad);
    inspect(WebEvent::PageUnload);

    println!("{:?}", Operations::Add)
}

fn inspect(event: WebEvent) {
    use WebEvent::{Click, KeyPress, PageLoad, PageUnload, Paste};
    match event {
        PageLoad => println!("page loaded"),
        PageUnload => println!("page unloaded"),
        KeyPress(v) => println!("pressed {}", v),
        Paste(s) => println!("pasted {}", s),
        Click { x, y } => {
            println!("clicked at x={} y={}", x, y)
        }
    }
}

enum WebEvent {
    PageLoad,
    PageUnload,
    KeyPress(char),
    Paste(String),
    Click { x: i64, y: i64 },
}

#[derive(Debug)]
enum VeryVerboseEnumOfThingsToDoWithNumbers {
    Add,
    Subtract,
}

// 创建一个类型别名
type Operations = VeryVerboseEnumOfThingsToDoWithNumbers;
